package com.hnkywl.sts.action.htgl;

import com.hnkywl.sts.entity.htgl.Bzjckll;
import com.hnkywl.sts.service.htgl.BzjckllService;
import net.ruixin.web.struts2.SimpleActionSupport;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.Date;

/**
 * Created by ccr on 2014/4/24.
 */
@Namespace("/htgl/bzjckllwh")
public class BzjckllAction extends SimpleActionSupport {
    private BzjckllService bzjckllService;
    private Bzjckll bzjckll;

    @Action("bzjckllList")
    public void bzjckllList(){
        renderJson(bzjckllService.bzjckllList());
    }

    @Action("bzjckll_xz")
    public String bzjckll_xz(){
        bzjckll = new Bzjckll();
        bzjckll.setRq(new Date());
        return SUCCESS;
    }

    @Action("save")
    public void save(){
        try {
            bzjckllService.save(bzjckll);
            renderText("{\"statusCode\":200,\"message\":\"操作成功\"}");
        } catch (Exception e) {
            e.printStackTrace();
            renderText("{\"statusCode\":300,\"message\":\""+e.getMessage()+"\"}");
        }

    }

    @Action("delete")
    public void delete(){
        try {
            bzjckllService.delete(bzjckll);
            renderText("{\"statusCode\":200,\"message\":\"操作成功\"}");
        } catch (Exception e) {
            e.printStackTrace();
            renderText("{\"statusCode\":300,\"message\":\""+e.getMessage()+"\"}");
        }

    }

    public Bzjckll getBzjckll() {
        return bzjckll;
    }

    public void setBzjckll(Bzjckll bzjckll) {
        this.bzjckll = bzjckll;
    }

    @Autowired
    public void setBzjckllService(BzjckllService bzjckllService) {
        this.bzjckllService = bzjckllService;
    }
}
